package com.kmxd.ams.app.arrange.command;

import cn.hutool.core.util.ObjectUtil;
import com.google.common.collect.Lists;
import com.kmxd.ams.client.archive.IArchiveTypeSvc;
import com.kmxd.ams.client.archive.vo.ArchiveTypeVO;
import com.kmxd.ams.client.system.ISysDictSvc;
import com.kmxd.ams.client.system.vo.SysDictItemListVO;
import com.kmxd.ams.core.common.constant.ArchConst;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 保管期限操作
 *
 * @author nickbi
 */
@AllArgsConstructor
@Component
public class RetentionPeriodCmd {
  private final IArchiveTypeSvc archiveTypeSvc;
  private final ISysDictSvc sysDictSvc;

  public List<SysDictItemListVO> rententionPeriodByArchType(Long archTypeId) {
    ArchiveTypeVO archiveTypeVO = archiveTypeSvc.view(archTypeId);
    if (ObjectUtil.isEmpty(archiveTypeVO)) {
      return Lists.newArrayList();
    }
    List<SysDictItemListVO> list =
        sysDictSvc.selectItemList(
            archiveTypeVO.getComId(), ArchConst.DICT_RETENTIONPERIOD, archiveTypeVO.getRpCodeId());
    if (ObjectUtil.isEmpty(list)) {
      return Lists.newArrayList();
    }
    return list;
  }
}
